package com.jrtc.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.jrtc.base.entity.bo.PrescriptionVideo;
import com.jrtc.dao.PrescriptionVideoDao;
import com.jrtc.service.PrescriptionVideoService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 运动处方动作视频表(PrescriptionVideo)表服务实现类
 *
 * @author makejava
 * @since 2022-09-09 15:26:45
 */
@Service("prescriptionVideoService")
public class PrescriptionVideoServiceImpl implements PrescriptionVideoService
{
    @Resource
    private PrescriptionVideoDao prescriptionVideoDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public PrescriptionVideo queryById(Integer id) {
        return this.prescriptionVideoDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<PrescriptionVideo> queryAllByLimit(int offset, int limit) {
        return this.prescriptionVideoDao.queryAllByLimit(offset, limit);
    }

    @Override
    public IPage<PrescriptionVideo> queryPrescriptionVideoList(PrescriptionVideo prescriptionVideo)
    {
        com.baomidou.mybatisplus.extension.plugins.pagination.Page<PrescriptionVideo> page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(prescriptionVideo.getPageNo(), prescriptionVideo.getPageSize() );
        IPage<PrescriptionVideo> prescriptionVideoPage = this.prescriptionVideoDao.queryPrescriptionVideoList(page, prescriptionVideo);
        return prescriptionVideoPage;
    }
    /**
     * 新增数据
     *
     * @param prescriptionVideo 实例对象
     * @return 实例对象
     */
    @Override
    public PrescriptionVideo insert(PrescriptionVideo prescriptionVideo) {
        this.prescriptionVideoDao.insert(prescriptionVideo);
        return prescriptionVideo;
    }

    /**
     * 修改数据
     *
     * @param prescriptionVideo 实例对象
     * @return 实例对象
     */
    @Override
    public PrescriptionVideo update(PrescriptionVideo prescriptionVideo) {
        this.prescriptionVideoDao.update(prescriptionVideo);
        return this.queryById(prescriptionVideo.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.prescriptionVideoDao.deleteById(id) > 0;
    }
}